package com.my.zl.console.controller.online;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.my.zl.common.dto.ReqDTO;
import com.my.zl.common.dto.ResDTO;
import com.my.zl.common.dto.advancedQuery.PageQueryDTO;
import com.my.zl.console.common.aop.LogAnnotation;
import com.my.zl.console.common.aop.NoLogAnnotation;
import com.my.zl.console.controller.base.BaseController;
import com.my.zl.console.dto.online.databaseSql.ReqDatabaseSqlAddDTO;
import com.my.zl.console.dto.online.databaseSql.ReqDatabaseSqlDelDTO;
import com.my.zl.console.dto.online.databaseSql.ReqDatabaseSqlDetailDTO;
import com.my.zl.console.dto.online.databaseSql.ReqDatabaseSqlEditDTO;
import com.my.zl.console.dto.online.databaseSql.ReqDatabaseSqlQueryDTO;
import com.my.zl.console.dto.online.databaseSql.ReqDatabaseSqlStateDTO;
import com.my.zl.console.dto.online.databaseSql.ResDatabaseSqlAddDTO;
import com.my.zl.console.dto.online.databaseSql.ResDatabaseSqlDelDTO;
import com.my.zl.console.dto.online.databaseSql.ResDatabaseSqlDetailDTO;
import com.my.zl.console.dto.online.databaseSql.ResDatabaseSqlEditDTO;
import com.my.zl.console.dto.online.databaseSql.ResDatabaseSqlQueryDTO;
import com.my.zl.console.dto.online.databaseSql.ResDatabaseSqlStateDTO;
import com.my.zl.console.service.online.IDatabaseSqlService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 数据库模板
 * @author ZL
 */
@Api(value="数据库模板",tags ="数据库模板")
@Controller
@RequestMapping("/api/online/databaseSql")
public class DatabaseSqlController extends BaseController {

    @Autowired
    private IDatabaseSqlService databaseSqlService;
    
    /**
     * 查询
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public ResDTO<ResDatabaseSqlQueryDTO> listDatabaseSql(ReqDatabaseSqlQueryDTO reqInfo,PageQueryDTO page) throws Exception{
        ResDatabaseSqlQueryDTO data = databaseSqlService.queryDatabaseSqlList(reqInfo,page);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/detail", method = RequestMethod.GET)
    public ResDTO<ResDatabaseSqlDetailDTO> detailDatabaseSql(ReqDatabaseSqlDetailDTO reqInfo) throws Exception{
        ResDatabaseSqlDetailDTO data = databaseSqlService.queryDatabaseSqlDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public ResDTO<ResDatabaseSqlAddDTO> addDatabaseSql(@RequestBody ReqDTO<ReqDatabaseSqlAddDTO> reqInfo) throws Exception{
        ResDatabaseSqlAddDTO data = databaseSqlService.insertDatabaseSqlInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/edit", method = RequestMethod.POST)
    public ResDTO<ResDatabaseSqlEditDTO> editDatabaseSql(@RequestBody ReqDTO<ReqDatabaseSqlEditDTO> reqInfo) throws Exception{
        ResDatabaseSqlEditDTO data = databaseSqlService.updateDatabaseSqlInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/del", method = RequestMethod.POST)
    public ResDTO<ResDatabaseSqlDelDTO> delDatabaseSql(@RequestBody ReqDTO<ReqDatabaseSqlDelDTO> reqInfo) throws Exception{
        ResDatabaseSqlDelDTO data = databaseSqlService.deleteDatabaseSqlInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @NoLogAnnotation
    @ResponseBody
    @RequestMapping(value="/state", method = RequestMethod.POST)
    public ResDTO<ResDatabaseSqlStateDTO> stateDatabaseSql(@RequestBody ReqDTO<ReqDatabaseSqlStateDTO> reqInfo) throws Exception{
        ResDatabaseSqlStateDTO data = databaseSqlService.updateDatabaseSqlState(reqInfo);
        return successDATA(data); 
    }
    
    
}